perm filename CH2[X3,LSP] blob sn#855615 filedate 1988-04-08 generic text, type C, neo UTF8
COMMENT ⊗   VALID 00002 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	∂08-Apr-88  1113	chapman%aitg.DEC@decwrl.dec.com 	new chapter 2    
C00055 ENDMK
C⊗;
∂08-Apr-88  1113	chapman%aitg.DEC@decwrl.dec.com 	new chapter 2    
Received: from decwrl.dec.com by SAIL.Stanford.EDU with TCP; 8 Apr 88  11:13:10 PDT
Received: by decwrl.dec.com (5.54.4/4.7.34)
	id AA27307; Fri, 8 Apr 88 11:12:58 PDT
Date: Fri, 8 Apr 88 11:12:58 PDT
Message-Id: <8804081812.AA27307@decwrl.dec.com>
From: chapman%aitg.DEC@decwrl.dec.com
To: rpg@sail.stanford.edu, CHAPMAN%aitg.DEC@decwrl.dec.com
Subject: new chapter 2

Dick,

The following is a more recent version of Chapter 2. Also, the next
mail message you get will be the file ready for printing on the LN03,
in case a hardcopy would be easier to look at.

kc

\input macros2

\beginChapter 2.{Common Lisp Standard Specification}%
{Evaluation}{Evaluation}

Author: Kathy Chapman

Revision: 4.0

\endTitlePage
 
\beginSection{Evaluation Model}
NOTE: Beginning of RPG/GLS rewrite.

Evaluation order {\function shall} be left-to-right for arguments not in
first position of {\word form} call. The argument in the first position
is evaluated last.

NOTE: End of RPG/GLS rewrite.

\beginSubsection{Scope}
NOTE: Beginning of Jonathan (??) rewrite.


The scope of a {\word binding} is that portion of a program in which the
{\word binding} is in effect. The scope of a variable thus
determines when and where the variable may be referenced.


Lexical scope is when a {\word binding} is 
in effect only from the code
written within the {\symbol form} that established it. 
Characteristics of lexical scope are as follows:
\beginlist

\item{\bull} {\word Form}s
called from the within the scope, but which are written elsewhere, never
see the lexical {\word binding}. 
\item{\bull} By default, {\word binding}s are lexical.
\item{\bull} Constructs that use lexical scope 
generate new variable location on each execution.
\item{\bull} An outer construct is one that textually occurs before
an inner construct.
\item{\bull} An inner construct is one that textually occurs within
an outer construct.
\item{\bull} If two constructs that establish a variable 
with the same name are textually nested, then references within the inner
construct refer to the variable 
established by the inner one; the inner one
shadows the outer one.  Outside the inner construct but inside the outer one,
references refer to the variable established by the outer construct.
\endlist 

Indefinite scope is when the {\word binding} is in effect anywhere,
in any {\word form}.

Dynamic scope is when the {\word binding} is in effect 
the whole time
it exists (except when it is {\word shadowed}), which includes time spent in
{\word form}s called from within the {\word binding} construct.
Dynamic scope is the same as 
indefinite scope and dynamic extent. 
{\word Special variable}s have dynamic scope. A {\word special variable}
can be referred to anywhere as long as its {\word bind}ing is currently
in effect.


Global scope is when a {\word binding} of dynamic scope lasts from the
beginning of the @clisp session to the end.



A free variable is a variable that is not used
within any {\word binding};
the reference to that variable is called lexically free.


Local {\word cell}s have lexical scope;
spacial {\word cell}s have global scope and can be referenced from anywhere
except where they are shadowed by a local {\word cell} referenced by the same
name. 

%Note that rules of lexical scoping are observed; if one of the functions
%mentioned has a lexically apparent local definition
%(as made by @Specref[flet] or @Specref[labels]), then the declaration
%applies to that local definition and not to the global function definition.


\endSubsection%{Scope}
\beginSubsection{Extent}

Dynamic extent is defined as 
an interval of time
(between establishment of the variable 
and the explicit disestablishment
of the variable) during which a variable 
reference may occur. A variable is disestablished when execution
of the establishing construct completes or terminates.
In the case of dynamic extent, if the time intervals of two 
variables
overlap, then one interval will necessarily be nested within the
other one.  
A reference by name to an variable with dynamic extent
will always refer to the variable of that name
that has been most recently established, and 
that has not yet been disestablished.



Indefinite extent is defined as an interval of time (between establishment
of the variable and possibility of reference of the
variable) during which a variable reference
may occur.
The {\word binding}s of {\word function} arguments have
indefinite extent.  

\endSubsection%{Extent}

\beginSubsection{Binding}
Rules concerning {\word binding} follow:
\beginlist

\item{\bull} @clisp has two kinds of {\word binding} - lexical and special.
Lexical {\word binding} creates a new
{\word cell}, while special {\word binding} has the effect of 
saving the {\word value} of a 
{\word cell}, giving it a new {\word value}
during the extent of the {\word binding}, and later restoring the 
old {\word value}.


\item{\bull} During the invocation of
a {\word function} represented by a {\word lambda-expression} 
(or a {\word closure} of
a {\word lambda-expression}, as produced by @Specref[function]),
new {\word binding}s are established for {\word lambda-expression}
arguments.

\item{\bull} The {\word value} a {\word special variable} 
has when there are currently
no {\word binding}s of that variable is called the global {\word value} of the
{\word special variable}.
A global {\word value} can be given to a variable only by assignment,
because a {\word value} given by {\word binding} is by definition not global.

\item{\bull} A {\word special variable} that has no {\word value}
is unbound
until
explicitly assigned a value, except for those {\word special variable}s
defined in this standard or by the {\word implementation} already to have 
initial {\word value}s
It is also possible to establish a {\word binding} of a {\word special variable}
and then cause that {\word binding} to be {\word value}less (unbound).
It is an error to refer to a variable that is unbound.


\item{\bull} When a {\word form} is exited,
the argument {\word binding}s, whether lexical or special, are
no longer in effect.  The {\word binding}s are not permanently discarded
if a
{\word closure} over that {\word binding} was created.


\item{\bull} It is an error to assign a {\word value} to, or create a {\word binding}
for a {\word constant}.


\item{\bull} {\word Lambda-expressions}
create {\word closure}s
over those non-{\word special variables} {\word binding}s in effect.
The {\word function} represented by a {\word lambda-expression}
may refer to any lexically apparent non-{\word special variable} and get the
correct {\word value}, even if the construct that established the {\word
binding}
has been exited in the course of execution.

\item{\bull} {\word Special variable} {\word binding}s are not
part of a created {\word closure}.

\endlist
\endSubsection%{Binding}
\beginSubsection{Rules/Examples}
Scope and extent rules in @clisp follow:
\beginlist

\item{\bull} 
Undeclared variables have lexical scope and indefinite extent.

\item{\bull} 
{\word Special variable}s have dynamic scope.

\item{\bull} A catcher established by {\function catch}
or {\function unwind-protect} has dynamic
scope.

\item{\bull} An exit point established by an iteration construct 
<must provide a list of those here> has lexical
scope and dynamic extent.  

\item{\bull} Targets
named by the tags in an iteration construct <must provide a list of those here> 
have lexical scope and dynamic extent.  

\item{\bull} Named constants such as have indefinite
scope and indefinite extent.

\endlist


Examples follow:
\beginlist
\item{1.}
@Lisp
(defun contorted-example (f g x) 
   (if (= x 0)  
       (funcall f)
       (block here 
   	    (+ 5 (contorted-example g 
  	       	                  \#'(lambda () 
                                       (return-from here 4)) 
 	       	                  (- x 1)))))) 
@Endlisp


Consider the call @f[(contorted-example nil nil 2)].  This produces
the result @f[4].  During the course of execution, there are three
calls on @f[contorted-example], interleaved with two establishments
of blocks:


@lisp
(contorted-example nil nil 2)  

  (block here1 ...) 

    (contorted-example nil 
                       \#'(lambda () (return-from here1 4)) 
                       1) 

      (block here2 ...) 
                                    
        (contorted-example \#'(lambda () (return-from here1 4))
  		 	   \#'(lambda () (return-from here2 4))
     			   0) 
          (funcall f)
     		where f @EV \#'(lambda () (return-from here1 4))

            (return-from here1 4) 
@endlisp 
At the time the {\function funcall} is executed
there are two {\function block} exit points outstanding, each apparently
named @f[here].  In the trace above, these exit points are distinguished
for expository purposes by appended integers.
The @Specref[return-from] form executed as a result of the @f[funcall]
operation
refers to the @i[outer] outstanding exit point
(@f[here1]), not the
inner one (@f[here2]).
This is a consequence of the rules of lexical scoping: it
refers to that exit point textually visible at the point of
execution of the @Specref[function]
construct (here abbreviated by the @f[\#'] syntax) that resulted
in creation of the {\word function} invoked by the {\function funcall}.

If, in this example, one were to change the form @f[(funcall f)] to
@f[(funcall g)], then the value of the call @f[(contorted-example nil nil 2)]
would be @f[9].  The value would change because {\function funcall} 
would cause the
execution of @f[(return-from here2 4)], thereby causing
a return from the inner exit point (@f[here1]).
When that occurs, @f[4] is returned from the
middle invocation of @f[contorted-example], @f[5] is added to that
to get @f[9], which is returned from the outer block
and the outermost call to @f[contorted-example].  The point
is that the choice of exit point returned from has nothing to do with its
being innermost or outermost; rather,
it depends on the lexical scoping information
that is effectively packaged up with a lambda-expression when the
@Specref[function] construct is executed.

@f[contorted-example] works only because the
@f[f] is invoked during the extent of the exit point.
Block exit points are like non-{\word special variable} {\word bindings} in having
lexical scope, but differ in having dynamic extent rather than indefinite
extent.  Once the flow of execution has left the {\function block}, 
the exit point is disestablished. 


\item{2.}
@lisp
(defun illegal-example () 
  (let ((y (block here \#'(lambda (z) (return-from here z))))) 
    (if (numberp y) y (funcall y 5)))) 
@endlisp 
One might expect the call @f[(illegal-example)] to produce @f[5]
by the following incorrect reasoning:
the @f[let] statement binds @f[y] to the
{\word value} of the @f[block] construct which is a {\word function} resulting
from the lambda-expression.  Because @f[y] is not a {\datatype number}, it is
invoked on @f[5].  The @Specref[return-from] should then
return this value from the exit point named @f[here], thereby
exiting from the block @i[again] and giving @f[y] the value @f[5]
which, being a {\datatype number}, 
is then returned as the value of the call
to @f[illegal-example].

The argument fails only because exit points are defined in @clisp
to have dynamic extent.  The argument is correct up to the execution
of the @Specref[return-from] which is an error
because it correctly refers to an exit point 
that has been disestablished.

 
\item{3.}
@lisp
(defun test (x z)
  (let ((z (* x 2))) (print z))
  z)
@Endlisp
The {\word binding} of the @f[z] by @Specref[let] {\word shadows}
the {\word binding} for @f[test].  
@f[z] in @Specref[print] refers to the @Specref[let] {\word binding}.
@f[z] at the end of the {\word function} refers to the 
{\word function} argument @f[z].



\item{4.} The {\word function} definition

@Lisp
(defun compose (f g)
  \#'(lambda (x) (funcall f (funcall g x))))
@Endlisp
when given two arguments, immediately returns a {\word function}.
The parameter {\word binding}s for @f[f] and @f[g] do not disappear because the
returned {\word function}, when called, could still refer to those {\word
binding}s.
Therefore

@lisp
(funcall (compose \#'sqrt \#'abs) -9.0)
@Endlisp
produces the value @f[3.0].  

\item{5.}
@Lisp
(defun fun1 (x)
  (catch 'trap (+ 3 (fun2 x))))


(defun fun2 (y)
  (catch 'trap (* 5 (fun3 y))))

(defun fun3 (z)
  (throw 'trap z))
@Endlisp
Consider the call @f[(fun1 7)].  The result will be @f[10].  At the time
the @Specref[throw] is executed, there are two outstanding catchers with the
name @f[trap]: one established within procedure @f[fun1], and the other
within procedure @f[fun2].  The latter is the more recent, and so
@f[7] is returned from @Specref[catch] in @f[fun2].
Viewed from within @f[fun3], @Specref[catch] in @f[fun2] 
{\word shadow}s @Specref[catch] in @f[fun1].
Had @f[fun2]
been defined as

@Lisp
(defun fun2 (y)
  (catch 'snare (* 5 (fun3 y))))
@Endlisp
then the two {\function catch}ers 
would have different names, and therefore the one
in @f[fun1] would not be {\word shadow}ed.  
The result would then have been @f[7].


\item{6.}
@lisp
(defun two-funs (x)
  (list (function (lambda () x))
        (function (lambda (y) (setq x y)))))
(setq funs (two-funs 6))
(funcall (car funs)) @EV 6
(funcall (cadr funs) 43) @EV 43
(funcall (car funs)) @EV 43
@endlisp
@f[two-funs] returns a {\datatype list} of two {\word function}s, 
each of which
refers to the {\word binding} of the variable @f[x] created on entry to
@f[two-funs] when it was called with argument @f[6].
@f[x] has the value @f[6] initially, but @Specref[setq] 
can alter
the {\word value} of @f[x]. The {\word lexical closure} 
created for the first {\word lambda-expression}
does not ``snapshot'' the {\word value} @f[6] 
for @f[x] when the {\word closure} is created.
The second function can be used to alter the {\word value} of 
@f[x] (to @f[43], in the
example), and this altered
{\word value} then becomes accessible to the first function.

NOTE: End of Jonathan (??) rewrite.

\endSubsection%{Rules/Examples}
\beginSubsection{Lisp Reader}

NOTE: Beginning of KC rewrite (comments from March meeting included, rewrite
not done yet)

The characters used in the syntax of @clisp follow:

\beginlist

\item{\bull} @f[(] -- Left parenthesis begins a {\datatype list} 
of items.  The {\datatype list} may
contain any number of items, including zero.  {\datatype List}s may be nested.


\item{\bull} @f[)] -- Right parenthesis ends a {\datatype list} of items.


\item{\bull} @f['] -- An accent acute (also called single quote or apostrophe)
followed by a {\datatype symbol}
is an abbreviation for ({\function quote} {\datatype symbol}).  


\item{\bull} @f[;] -- Semicolon is the comment character.  It and all characters up to the
end of the line are discarded.


\item{\bull} @f["] -- Double quotes surround {\datatype string}s.


\item{\bull} @f[\\] -- Backslash is an escape character.  It causes the
next character to be treated as a letter rather than for its usual
syntactic purpose.  For example, @f[A\\(B] denotes a symbol whose name is
consists of the three characters @f[A], @f[(], and @f[B].
Similarly, @f["\\""] denotes a {\datatype string} containing 
one {\datatype character},
a double quote, because the first and third double quotes serve to
delimit the {\datatype string}, 
and the second double quote serves as the contents
of the {\datatype string}. The backslash causes the second double quote to
be taken literally, and prevents it from
being interpreted as the terminating delimiter of the {\datatype string}.


\item{\bull} @f[|] -- Vertical bars are used in pairs
to surround the name (or part of the name) of a {\datatype symbol} that has
many special characters in it.  For example,
@f[|A(B)|], @f[A|(|B|)|], and @f[A\\(B\\)] all mean the {\datatype symbol} 
whose name
consists of the four characters @f[A], @f[(], @f[B], and @f[)].


\item{\bull} @f[\#] -- Number sign signals the beginning of a complicated
syntactic structure.
\beginlist
\itemitem{--} Binary, octal, and
hexadecimal radices are useful enough to warrant the special
abbreviations @f[\#b] for @f[\#2r], @f[\#o] for @f[\#8r], and
@f[\#x] for @f[\#16r].
For example, @f[\#o105] means 105${}\sub 8$ (105 in octal notation);
@f[\#x105] means 105${}\sub 16$ (105 in hexadecimal notation);
@f[\#b1011] means 1011${}\sub 2$ (1011 in binary notation);
Only legal digits
for the specified radix may be used. See Figure 3-1.
\boxfig
{\dimen0=.75pc
\tabskip \dimen0 plus .5 fil
\halign to \hsize {#\hfil\tabskip \dimen0 plus 1fil&#\hfil\tabskip\dimen0 plus
.5 fil\cr
\noalign{\vskip -9pt}
\hfil\bf  Example\span\omit\cr
\noalign{\vskip 2pt\hrule\vskip 2pt}
\#2r11010101  &;@r[Another way of writing @f[213] decimal] \cr
\#b11010101  &;@r[Ditto] \cr
\#b+11010101  &;@r[Ditto] \cr
\#o325  &;@r[Ditto, in octal radix] \cr
\#xD5  &;@r[Ditto, in hexadecimal radix] \cr
\#16r+D5  &;@r[Ditto] \cr
\#o-300  &;@r[Decimal -192, written in base 8] \cr
\#3r-21010  &;@r[Same thing in base 3] \cr
\#25R-7H  &;@r[Same thing in base 25] \cr
\#xACCEDED  &;@r[181202413, in hexadecimal radix] \cr
\noalign{\vskip -9pt}
}}
\caption{}
\endfig


\itemitem{--} Complex numbers may be notated by writing the characters @f[\#C]
followed by a {\datatype list} 
of the real and imaginary parts. See Figure 3-2.
\boxfig
{\dimen0=.75pc
\tabskip \dimen0 plus .5 fil
\halign to \hsize {#\hfil\tabskip \dimen0 plus 1fil&#\hfil\tabskip 
\dimen0 plus 1fil\cr
\noalign{\vskip -9pt}
\hfil\bf  Example\span\omit\cr
\noalign{\vskip 2pt\hrule\vskip 2pt}
\#C(3.0s1 2.0s-1) & \cr
\#C(5 -3)      &	;@r[A Gaussian integer] \cr
\#C(5/3 7.0) & ;@r[Will be converted internally to \#C(1.66666 7.0)] \cr
\#C(0 1)	      &	;@r[The imaginary unit, that is, i] \cr
\noalign{\vskip -9pt}
}}
\caption{}
\endfig
\itemitem{--} @f[\#\\L] denotes the {\datatype character} 
@f[L]; 
the syntax for {\datatype character} names after @f[\#\\]
is the same as that for {\datatype symbol}s (see Data Types).  
The font attribute is an unsigned decimal {\datatype integer}
positioned syntactically between the @f[\#] and the @f[\\].  For example,
@f[\#3\\a] means the letter @f[a] in font 3.


The bits attribute is an unsigned decimal {\datatype integer}
preceding the name of the character by the names or initials
of the bits,
separated by hyphens.  The character itself may be written
instead of the name, preceded if necessary by @f[\\].
\itemitem{--} @f[\#\\Newline] -- @f[\#\\Newline] is the line
delimiter.  
\itemitem{--} @f[\#(a b c)] denotes a {\datatype vector} 
of three elements @f[a], @f[b], and @f[c].
\itemitem{--} @f[\#:bar] -- The {\word Lisp reader} will create a new {\datatype
symbol} named @f[bar] on encountering these characters.
\itemitem{--} @f[\#<] -- The {\word Lisp reader} will signal an error on encountering 
these characters.
\endlist

\item{\bull} @f[`] -- Accent grave (``backquote'') signals that the next expression
is a template that may contain commas.  


\item{\bull} @f[,] -- Commas are used within the backquote syntax.


\item{\bull} @f[:] -- Colon is used either to indicate to which 
{\datatype package} a {\datatype symbol} belongs.
For example, @f[network:reset] denotes the {\datatype symbol} named @f[reset]
in the {\datatype package} 
named @f[network].
The colon character is not actually part of the {\word print name}
of the {\datatype symbol}.


\item{\bull} @f[::] -- Double colon is 
used to refer to a {\datatype symbol} in another 
{\datatype package}.
The {\word value} of [editor::buffer] is the same as
the {\word value} of @f[buffer] with {\symbol package}
temporarily rebound to the
package whose name is @f[editor].  



\endlist



Other syntactic rules follow:

\beginlist


\item{\bull} 
@clisp is insensitive to the case in which code
is written.  Internally, names of {\datatype symbol}s and {\datatype package}s
are
converted to and stored in uppercase form.





\item{\bull} The @clisp {\datatype character}s are
used for writing programs that can
be read by a @clisp {\word implementation}, and for 
{\datatype character}s as data.
The @clisp {\datatype character}s are as follows: a space 
@f[\#\\Space], a newline @f[\#\\Newline], and these ninety-four
non-blank printing {\datatype character}s:

@Lisp
  ! " \# \$ \% \& ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ?
  A B C D E F G H I J K L M N O P Q R S T U V W X Y Z @lbracket \\ @rbracket \↑ _
  a b c d e f g h i j k l m n o p q r s t u v w x y z { | } @tilde
@Endlisp
Two additional {\datatype character}s are ATsign and backquote.
The @clisp standard character set is equivalent to
the ninety-five standard ASCII printing characters plus \\\#Newline.
Uppercase and lowercase letters {\function shall} be ordered according to their appearance
in the alphabet (as above).

\item{\bull} {\datatype Ratio}s are written as 
an optional sign followed by two non-empty sequences of
digits separated by a @f[/]. 
A {\datatype ratio} is presented
as an {\datatype integer} 
if its {\word value} is integral, otherwise it is
presented as the numerator and denominator separated by a /.
{\datatype Ratio}s may also be denoted in radices other
than ten.
%See Figure {\chapno--\the\capno}. The syntax follows:
%
%\cboxfig{
%\leftskip 2pc
%\cleartabs\settabs\+\hskip\leftskip&\cr
%\+&{\bf ratio} ::$=$ $\lbrack${\it sign}$\rbrack$ \plus{\curly{digit$\sub 1$}}
%/ \plus{\curly{digit$\sub 2$}}  \cr
%\Vskip 1pc!
%}
%\caption{}

%{\it digit$\sub 2$} must be non-zero.
%See Chapter 8 for the metanotation definitions used to describe 
%@clisp syntactically.

\boxfig
{\dimen0=.75pc
\tabskip \dimen0 plus .5 fil
\halign to \hsize {#\hfil\tabskip \dimen0 plus 1fil&#\hfil\tabskip \dimen0 plus 1fil\cr
\noalign{\vskip -9pt}
\hfil\bf  Example\span\omit\cr
\noalign{\vskip 2pt\hrule\vskip 2pt}
2/3  		      &	;@r[This is in canonical form] \cr
4/6		      &	;@r[A non-canonical form for the same number] \cr
-17/23		      &	;@r[A ratio preceded by a sign] \cr
-30517578125/32768    &	;@r[This is $(-5/2)↑15$] \cr
10/5		      &	;@r[The canonical form for this is 2] \cr
}}                  
\caption{}
\endfig

\item{\bull} 
\label Floating-point Number Syntax:
TBS.
%\cboxfig{
%\leftskip 2pc
%\cleartabs\settabs\+\hskip\leftskip&\cr
%\+&{\bf floating-point-number} ::$=$ $\lbrack\${\it sign}$\rbrack\$
%\upstar{\curly{digit}} {\it decimal-point} \plus{\curly{digit}}  
%$\lbrack\${\it exponent}$\rbrack\$ $\vert$ \cr
%
%%$\lbrack\${\it sign}$\rbrack\$\plus{\curly{digit}}$\lbrack\$ {\it decimal-point} 
%%\upstar{\curly{digit}}
%%$\rbrack\$
%%{\it exponent} \cr
%\Vskip 1pc!
%\+&{\it sign\/} ::$=$ @f[+] $\vert$   @f[-] \cr
%\Vskip 1pc!
%\+&{\it decimal-point} ::$=$ @f[.] \cr
%\Vskip 1pc!
%\+&{\it digit} ::$=$ @f[0] $\vert\$ @f[1] $\vert$ @f[2] $\vert$ @f[3] $\vert$ 
%@f[4] $\vert$ @f[5] $\vert$ @f[6] $\vert$ @f[7] $\vert$ @f[8] $\vert$ @f[9]
%\cr
%\Vskip 1pc!
%\+&{\it exponent} ::$=$ {\it exponent-marker} $\lbrack${\it sign}$\rbrack$ 
%\plus{\curly{digit}}  \cr
%\Vskip 1pc!
%\+&{\it exponent-marker} ::$=$ @f[e] $\vert\$ @f[s] $\vert\$ @f[f] $\vert$ 
%@f[d] $\vert$ @f[l] $\vert$ @f[E] $\vert$ @f[S] $\vert$ @f[F] $\vert$ 
%@f[D] $\vert$ @f[L]
%\Vskip 1pc!
%}
%\caption{Syntax for Floating-point numbers}
%\endfig


\item{\bull} Floating-point {\datatype number}s are written in either 
decimal fraction
or computerized scientific notation: an optional sign,
then a non-empty sequence of digits with an embedded decimal point,
then an optional decimal exponent specification.
If there is no exponent specifier, then
the decimal point is required, and there must be digits
after it.
The exponent specifier consists of an exponent marker,
an optional sign, and a non-empty sequence of digits.
If no exponent specifier is present, or if the exponent marker @f[e]
(or @f[E]) is used, then the precise format to be used is not
specified.  When such a representation is read and
converted to an internal floating-point data {\word value}, the format specified
by @Varref[read-default-float-format] is used, whose initial
{\word value} is @f[single-float].

\item{\bull} The print name of a {\datatype symbol} can be composed
of the following {\datatype character}s:

%@Lisp
% A-Z a-z \$ \% \& * + - . / < >  \\  \↑ @underscore @tilda
%@
%@Endlisp
with the following restrictions:
\beginlist
\itemitem{--} A print name can not be composed of only one or more periods
(.).
\itemitem{--} A print name can not be syntactically identical to a 
{\datatype number}.
\endlist

Following are rules for interpreting a {\datatype symbol}'s print name:
\beginlist
\itemitem{--} @f[foo:bar]  -- When read, looks up @f[BAR] among the external 
{\datatype symbol}s of
the {\datatype package} named @f[FOO].  Printed when 
{\datatype symbol} @f[bar] is external in its
home {\datatype package} @f[foo] and is not accessible in the current 
{\datatype package}.

\itemitem{--} @f[foo::bar]  -- When read, interns @f[BAR] as if @f[FOO] were the
current {\datatype package}. Printed when 
@f[bar] is internal in its home {\datatype package}
@f[foo] and is not accessible in the current {\datatype package}.

\itemitem{--} @f[:bar]  -- When read, interns @f[BAR] as an external 
{\datatype symbol} in the
@f[keyword] {\datatype package}, and makes it evaluate to itself.  Printed when
the home package of @f[bar] is @f[keyword].
                
\itemitem{--} @f[\#:bar]  -- When read, creates a new uninterned {\datatype symbol} 
named @f[BAR].
Printed when @f[bar] is uninterned (has no home {\datatype package}),
even in the pathological case that @i[bar] is uninterned but
nevertheless somehow accessible in the current {\datatype package}.
\endlist

\item{\bull} A {\datatype List} is written
as follows: a left parenthesis is first, followed by the 
{\word value}s composing
the {\symbol list} separated by blank space, followed by a right parenthesis.

\item{\bull} {\datatype Vector}s are written by placing a \# before a left
parenthesis, following that with the elements of the {\datatype vector}, and
then concluding with a right parenthesis.

\item{\bull} {\datatype Bit-vector}s are written as successive bits 
preceded by @f[\#*]; any delimiter character, such as whitespace,
will terminate the {\datatype bit-vector}.

$$\vbox{\halign{\strut#\hfil&\quad\hfil#\hfil\cr
{}&\bf Example\cr
\noalign{\hrule}
$\#*10110$	      &	;@r[A five-bit bit-vector; bit 0 is a 1] \cr
$\#*$		      & ;@r[An empty bit-vector] \cr}}$$

The bits notated following the @f[$\#*$], taken from left to right,
occupy locations within the {\datatype bit-vector} with increasing indices.
The leftmost bit is element number 0, the next one
is element number 1, and so on.

\item{\bull} A {\datatype string} is denoted
as follows: a double quote  precedes {\datatype string-char}s
which are followed by a double quote. Within the {\datatype string},
double quotes and backslash {\datatype string-char}s must be preceded
by a backslash (the single {\datatype character} ``escape'' signal).
The vertical bar (not preceded by a \\) is used as a \\ that may be 
followed by multiple {\datatype character}s, and must be followed by 
another vertical bar (not preceded by a \\).
Double quotes can be present within vertical bars without being preceded by
a backslash.                           



\item{\bull} All {\word special variable}s 
defined by a @clisp {\word implementation} have names beginning and ending with
asterisks.

\item{\bull} The syntax for {\word lambda-expressions} is the following: 
TBS
%{\tt (lambda {\it lambda-list\/} \star{\curly{declaration $\vert$ documentation}} \star{\curly{form}})}
%\cboxfig{
%\cleartabs\settabs\+\hskip\leftskip&\cr
%\+&{\it lambda-list\/}::$=$ (&\star{\curly{var}}  \cr
%\+&&\ttbrac{{\opt} \star{\curly{var $\vert$ {\rm (}var \ttbrac{initform {\brac{supplied-p-parameter}} }{\rm )}}}}  \cr
%\+&&\ttbrac{{\tt\&rest} {\it var\/}} \cr
%\+&&{\tt [}{\key{}}&\star{\curly{var  $\vert$
%{\rm (}\curly{var $\vert$ {\rm (}keyword var{\rm )}}
%\ttbrac{initform \brac{supplied-p-parameter} }{\rm )}}}\cr
%\+&&&\brac{\tt\&allow-other-keys} {\tt ]} \cr
%\+&&\ttbrac{{\tt\&aux} \star{\curly{var $\vert$ 
%{\rm (}var \brac{initform} {\rm )}}}} {\rm )} \cr
%}



\endlist


The rules for determining
what {\word cell} is referenced when a program mentions a 
variable 
are as follows:


\beginlist

\item{\bull} When the {\word Lisp reader} has encountered 
a variable, its name is looked up in the current 
{\datatype package}.
This lookup may involve looking in other 
{\datatype package}s whose external {\datatype symbol}s
are inherited by the current {\datatype package}.  If the name is found,
the corresponding {\datatype symbol} is returned.  If the name is not found
(that is, there is no {\datatype symbol} 
of that name accessible in the current {\datatype package}),
a new {\datatype symbol} 
is created for it and is placed in the current {\datatype package} as an
internal {\datatype symbol}.  
The current {\datatype package} becomes the owner
(home {\datatype package}) of the {\datatype symbol}, 
and so the {\datatype symbol} becomes interned
in the current {\datatype package}.
If the name is later read again while this same {\datatype package} is
current, the same {\datatype symbol} will then be found and returned.

\item{\bull} @f[editor:buffer] refers to the external {\datatype symbol} 
named @f[buffer]
accessible in the {\datatype package} named @f[editor], regardless of whether
there is a {\datatype symbol} 
named @f[buffer] in the current {\datatype package}.  If there
is no {\datatype package} named @f[editor], or if no 
{\datatype symbol} named @f[buffer]
is accessible in @f[editor], or if @f[buffer] is an internal
{\datatype symbol} in @f[editor], the {\word Lisp reader} will signal
a correctable error to ask the user what he really wants to do.


\item{\bull} A lexically bound variable can be referred to only
by {\word form}s occurring at any place 
textually within the {\word form} that
binds the variable. A dynamically bound variable (i.e. {\word special variable}
can
be referred to at any time from the time the {\word binding} is made
until the time {\word evaluation} of the {\word form} that binds the 
variable 
terminates.  Lexical {\word binding} of variables 
imposes a spatial limitation
on occurrences of references.  
Conversely, dynamic {\word binding} of variables imposes a temporal
limitation on occurrences of references.






\endlist



NOTE: End of KC rewrite.

\endSubsection%{Lisp Reader}
\endSection%{Evaluation}
\beginSection{Interpreted and Compiled Environments}



In an interpreted environment,
the evaluator is invoked automatically in the top-level read-eval-print
loop.  This is the interpretive mode of interaction with the
system in which the user types in a {\word form}, the 
{\word form} is read by the
{\word Lisp reader}, it is evaluated by the evaluator, and the
resulting {\word value}(s) is printed out for the user's inspection.
The read-eval-print loop then automatically re-enters
a state in which it is 
again waiting for the user to enter a {\word form}. 





The  compiler transforms @clisp code into a form
that is more efficient to execute than interpreted code.


A difference between the interpreter and the compiler lies
in the treatment of declarations.  Those declarations that are ignored by the
interpreter are often used by the compiler as advice in order to produce faster
and more efficient code.  This applies in particular to 
type declarations.
                                                 
                                                                  
The interpreter and compiler {\function shall} impose identical semantics
on correct programs. This means that ...

\endSection%{Interpreted and Compiled Environments}

\beginSection{Compile/Load/Run Environments}
The set of {\word binding}s that are visible at a given point
in a program is termed the {\bit environment}.  The {\bit lexical
environment\/} consists of those lexical {\word binding}s that are visible at
a particular point in the program, as determined by the structure of the
program text.  The lexical environment of a top-level form is termed the
null lexical environment.  
This environment has no lexical {\word binding}s.
The {\bit dynamic environment\/} consists
of those dynamic {\word binding}s that are visible at a particular point during
program execution, as determined by the dynamic execution of
the program.  The dynamic environment is also referred to as the
{\bit global environment}.

\endSection%{Compile/Load/Run Environments}
\bye